<?php
/**
 * Created by PhpStorm.
 * User: cape
 * Date: 2017/11/15
 * Time: 8:15
 */


$mysqli = mysqli_connect("127.0.0.1:3306", "root", "root", "test");
$res = mysqli_query($mysqli, "SELECT 'Please, do not use ' AS _msg FROM DUAL");
$row = mysqli_fetch_assoc($res);
echo $row['_msg'];

echo '<hr/>';

$mysqli = new mysqli('localhost', 'root', 'root', 'test', '3306');
if ($mysqli ->connect_errno){
    echo "Failed to connect to MYSQL: " . $mysqli->connect_errno;
}


$res = $mysqli->query("SELECT 'choices to please everybody.' AS _msg FROM DUAL");
$row = $res->fetch_assoc();
echo $row['_msg'];


echo '<hr/>';

$connection = new mysqli('localhost', 'root', 'root', 'test');
if ($connection->connect_errno){
    die('Connect Error (' . $connection -> connect_errno() . ')' . $connection->connect_error());
}else{
    echo '连接成功';
}









